package com.ecloud.common;

/**
 * @author Squbi
 */
public class Page {
    private int pageIndex;
    private final int pageSize;

    /**
     * 构造为页面大小
     *
     * @param pageSize 页面大小 final
     * @author Squbi
     * @date 2021/7/26 9:40
     */
    public Page(int pageSize) {
        this.pageIndex = 0;
        this.pageSize = pageSize;
    }

    public Page(int pageIndex, int pageSize) {
        this.pageIndex = pageIndex;
        this.pageSize = pageSize;
    }

    /**
     * limit的左下标
     *
     * @return int
     * @author Squbi
     * @date 2021/7/26 9:42
     */
    public int limitL() {
        return pageIndex;
    }

    /**
     * limit的右偏移
     *
     * @return int
     * @author Squbi
     * @date 2021/7/26 9:42
     */
    public int limitR() {
        return (pageIndex - 1) * pageSize;
    }

    /**
     * 下一页
     *
     * @author Squbi
     * @date 2021/7/26 9:42
     */
    public void nextPage() {
        pageIndex++;
    }
}
